home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // get lots of information about a nurbs curve
- proc float[] getNurbsCurveKnots(
- string $crvName )
- //
- // Description :
- //
- {
- float $knots[] ;
- string $infoNode ;
-
- // create info Node.
- if( catch( $infoNode = `createNode curveInfo` ) ) {
- return $knots ;
- }
-
- // connect curve on to the info node.
- //
- string $outAttr = $crvName + ".local" ;
- string $inAttr = $infoNode + ".ic" ;
- connectAttr $outAttr $inAttr ;
-
- // read the knots.
- //
- $outAttr = $infoNode + ".knots" ;
- $knots = `getAttr $outAttr` ;
-
- // delete curve info node.
- //
- delete $infoNode ;
-
- // return the knots.
- //
- return $knots;
- }
-
- global proc printNurbsCurveMiscInfo(string $crv)
- // Description :
- // prints the knot values
- {
- // form
- int $form = eval("getAttr " + $crv + ".form");
- $w = "Form: " + $form + " (0 = open, 1 = closed, 2 = periodic)\n";
- print $w;
-
- // degree
- int $degree = eval("getAttr " + $crv + ".degree");
- $w = "Degree: " + $degree + "\n";
- print $w;
-
- // number of spans
- int $nspans = eval("getAttr " + $crv + ".spans");
- $w = "Nspans: " + $nspans + "\n";
- print $w;
-
- // bounding box (what if it is 2d??)
- float $minBox[] = eval("getAttr " + $crv + ".boundingBoxMin");
- $w = "Bounding box min: " + $minBox[0] + " " + $minBox[1] + " " + $minBox[2] + "\n";
- print $w;
-
- float $maxBox[] = eval("getAttr " + $crv + ".boundingBoxMax");
- $w = " max: " + $maxBox[0] + " " + $maxBox[1] + " " + $maxBox[2] + "\n";
- print $w;
-
- }
-
- global proc printNurbsCurveKnots(string $crv)
- // Description :
- // prints the knot values
- {
-
- float $knots[] = getNurbsCurveKnots($crv);
- print "Knots: ";
- int $numKnots = size($knots);
- for($i=0; $i<$numKnots; $i++) {
- $w = " " + $knots[$i];
- print $w;
- }
- print "\n";
-
- }
-
- global proc printNurbsCurveCVs(string $crv)
- // Description :
- // prints the CV positions in world space
- {
-
- // create info Node.
- string $infoNode = `createNode curveInfo`;
-
- // connect curve on to the info node.
- string $outAttr = $crv + ".ws[0]" ;
- string $inAttr = $infoNode + ".ic" ;
- connectAttr $outAttr $inAttr ;
-
- // CVs
- int $numCVs = `getAttr -size ($infoNode + ".cp")`;
-
- $w = "Number of CVs: " + $numCVs + "\n";
- print $w;
-
- float $cv0[] = `getAttr ($infoNode + ".cp[0]")`;
- int $dim = size($cv0);
- $w = "Dimension of curve: " + $dim + "\n";
- print $w;
-
- // print out the CV positions
- print "CVs in world space:\n";
- for($i=0; $i<$numCVs; $i++) {
- float $cvs[] = `getAttr ($infoNode + ".cp[" + $i + "]")`;
- $w = $i + ": ";
- for($j=0; $j<$dim; $j++) {
- $w += $cvs[$j] + " ";
- }
- $w += "\n";
- print $w;
- }
-
- // tidy up
- delete $infoNode ;
- }
-
- global proc nurbsCurveInformation()
- {
- string $w; // for messages
-
- // 0. Grab the select list.
- //
- string $selList[] = `ls -sl`;
-
- // 1. Run filter to select only the NURBS curves and curves on surface
- //
- global int $gSelectNurbsCurvesBit ;
- global int $gSelectCurvesOnSurfacesBit;
-
- string $crvList[] = `filterExpand -ex true
- -sm $gSelectNurbsCurvesBit
- -sm $gSelectCurvesOnSurfacesBit $selList` ;
- int $len = size($crvList) ;
- if( $len == 0 ) {
- print "No NURBS curve selected" ;
- return;
- }
-
- // 2. Work on the last item if more than one NURBS curve in list.
- //
- for($crvNum = 0; $crvNum < $len; $crvNum++) {
- string $crv = $crvList[$crvNum] ;
-
- // print separator if more than one curve
- if($len>1) print "----------------------------------\n";
-
- // curve name
- $w = "Curve: " + $crv + "\n";
- print $w;
-
- // print out the form,degree,nspans,bbox
- printNurbsCurveMiscInfo($crv);
-
- // print out the knots
- printNurbsCurveKnots($crv);
-
- // print out the CVs
- printNurbsCurveCVs($crv);
- }
-
- // print separator if more than one curve
- if($len>1) print "----------------------------------\n";
-
- // reselect curve for which information was returned
- select -r $selList;
- }
-
-